[% pagetitle = "SAVED_PLAYLISTS" | string;
pageicon = 'SAVED_PLAYLISTS';
IF NOT ajaxUpdate;
IF playlist.title; title = playlist.title; ELSE; title = 'PLAYLIST' | string; END;
homeString = 'PLAYLIST' | string;
goHomeURI = 'href = "' _ webroot _ 'browsedb.html?hierarchy=playlist,playlistTrack&level=0&&player=' _ playerURI _ '"';
PROCESS iHeaderVert.html dontscroll = 1 %]

<script>
function doDeletePlaylist(arg) {
	var temp = confirm ("Are you sure you want to delete this playlist?");
	if (temp) {
		var sArray = ["playlists", "delete", "playlist_id:" + arg];
		callJSONRPC(sArray, function (r2) {var href; returnToLevel([% goHomeURI %]);}, function (r2) {});
	}
}
function doRenamePlaylist(arg) {
 function reallyDoRename(response, arg, name) {
	if (response.result.overwritten_playlist_id && (response.result.overwritten_playlist_id != arg))
		if (!confirm("A Playlist of that name already exists. Do you want to overwrite it?")) return;
		var sArray = ["playlists", "rename", "playlist_id:" + arg, "newname:" + name ];
		callJSONRPC(sArray, function (r2) { 
		 	var elTitle = $('title');
		 	if (name.length > 15) {
		 		elTitle.style.fontSize = "80%";
		 		elTitle.style.padding = "3 0"
				elTitle.textContent = name.truncate(18);
			} else {
		 		elTitle.style.fontSize = "100%";
		 		elTitle.style.padding = "0"
				elTitle.textContent = name;
			}
		}, function (r2) {});
 }
	var temp = confirm ("Are you sure you want to rename this playlist?");
	if (temp) {
	 	var name = $('newname').value;
		var sArray = ["playlists", "rename", "playlist_id:" + arg, "newname:" + name, "dry_run:1" ];
		callJSONRPC(sArray, function (r2) { reallyDoRename (r2, arg, name); }, function (r2) {alert("why nosuccess?");});
	}
}
</script>


[% IF page_vertical %]
<div style = "position: relative; height: 44; border: 0; padding: 0;">&nbsp;</div>  <!-- spacer to keeps margins from collapsing on safari -->
[% END %]

<script>
	storeReturnLevel();
	storeReturnPage();
</script>

	[% IF warn %]<b>[% "NOTE" | string %]</b> [% "SCAN_WARNING" | string %]<p> <hr>[% END %]
	
	[% UNLESS noEdit %]
	<div class="playlistform">
	<form id = "editPlaylist" method="get" action="edit_playlist.html">
	<table style = "margin: 0px 11px;">
		<colgroup>
		<col width = "33%">
		<col width = "33%">
		<col width = "33%">
		</colgroup>
		<tr>
		<td colspan = 3>
		<label>[% "NAME" | string %]&nbsp;</label>
		<input class="stdedit" id="newname" name="newname" value="[% IF newname; newname; ELSE; playlist.title; END %]" size="[% maxInputSize ? maxInputSize : 40 %]"></td>
		</tr><tr>
		<td><a class="iButton silver" style = "height: 32; padding: 0;" value="[% "SAVE" | string %]" onclick='doRenamePlaylist([% playlist.id %]);'>[% "SAVE" | string %]</a></td>
		<!--td><a class="iButton silver" style = "height: 32; padding: 0;" value="[% "EDIT" | string %]" onclick='document.forms["editPlaylist"].submit();'>[% "EDIT" | string %]</a></td-->
		<td><a class="iButton silver" style = "height: 32; padding: 0; color: #888888;" value="[% "EDIT" | string %]">[% "EDIT" | string %]</a></td>
		[% IF playlist.title && playlist.title != untitledString %]
			<td><div class="iButton red" style = "height: 32; padding: 0;" value="[% "DELETE" | string %]" onclick='doDeletePlaylist([% playlist.id %]);'>[% "DELETE" | string %]</div></td>[%# "DELETE_WARNING" | string %]</a>
		[% END %]
			<input type="hidden" name="playlist.id" value="[% playlist.id %]">
			<input type="hidden" name="renamePlaylist" value="0">
			<input type="hidden" name="editPlaylist" value="1">
			<input type="hidden" name="deletePlaylist" value="0">
			<input type="hidden" name="dir" value="[% dir %]">
			<input type="hidden" value="[% player %]" name="player">
		</td>
		</tr></table>
	</form></div>
	[% END %]
		[% IF hasPagebar %]
			<div id="crumblist_vert">
			[% PROCESS pagebar %]
			</div>
		[% END %]
[% END %] 

<div id = 'pagecontainer_vert'>
<div style = "float: right; top: 0; right: 0; width: 0; height: 222px; padding: 0; border: 0; margin: 0; overflow: hidden;">&nbsp;</div> <!-- keep buttons at bottom -->

<table width = '100%' class = 'noborder listNoAlbum' cellspacing = "0" bgcolor = 'white' border = "collapse">
	[%- IF browse_items;
		FOREACH item = browse_items;
			PROCESS browsedbitems_list.html noLink=item.descend; # <!--(levelName == 'track') -->
		END;
	ELSE;
		browse_list;
	END;
'</table>';

'</div>';

IF NOT ajaxUpdate;
	IF hasPagebar %]
		<div id="crumblist_vert">
		[% PROCESS pagebar;
	END;
	'</div>';

	PROCESS iFooterVert.html;
END %]
